package org.tr.generator;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * User: Lior Ben Zeev
 * Date: Oct 11, 2011
 */
public class TimeRunnerTimer extends Timer {
    public TimeRunnerTimer() {
        super();
    }

    public TimeRunnerTimer(boolean isDaemon) {
        super(isDaemon);
    }

    public TimeRunnerTimer(String name) {
        super(name);
    }

    public TimeRunnerTimer(String name, boolean isDaemon) {
        super(name, isDaemon);
    }

    @Override
    public void schedule(TimerTask task, long delay) {
        super.schedule(task, Generator.calcNewInterval(delay));
    }

    @Override
    public void schedule(TimerTask task, long delay, long period) {
         super.schedule(task, Generator.calcNewInterval(delay), Generator.calcNewInterval(period));
    }

    @Override
    public void schedule(TimerTask task, Date firstTime, long period) {
        super.schedule(task, firstTime, Generator.calcNewInterval(period));
    }

    @Override
    public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) {
        super.scheduleAtFixedRate(task, firstTime, Generator.calcNewInterval(period));
    }

    @Override
    public void scheduleAtFixedRate(TimerTask task, long delay, long period) {
        //System.out.println("Period: "+period);
        //System.out.println("Period2: "+period/Generator.getSpeed());
        super.scheduleAtFixedRate(task, delay, Generator.calcNewInterval(period));    //To change body of overridden methods use File | Settings | File Templates.
    }

}
